package com.example.contactapp;

import android.content.Intent;
import android.os.Bundle;

import android.view.animation.AlphaAnimation;

import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView welcomeText;
    private Button startButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        welcomeText = findViewById(R.id.welcome_text);
        startButton = findViewById(R.id.start_button);

        // 动画效果
        AlphaAnimation fadeInAnimation = new AlphaAnimation(0.0f, 1.0f);
        fadeInAnimation.setDuration(1500);  // 动画持续时间
        fadeInAnimation.setFillAfter(true);  // 动画结束后保持最终状态

        welcomeText.setAnimation(fadeInAnimation);

        // 按钮点击事件
        startButton.setOnClickListener(v -> {
            Intent intent = new Intent(MainActivity.this, LoginActivity.class);
            startActivity(intent);
        });

        try (DatabaseHelper dbHelper = new DatabaseHelper(this)) {
            dbHelper.getWritableDatabase(); // 初始化数据库
        }
    }
}